# https://leetcode-cn.com/problems/loud-and-rich/
# 851. 喧闹和富有

import queue
from typing import List


class Solution:
    def loudAndRich(self, richer: List[List[int]], quiet: List[int]) -> List[int]:
        n = len(quiet)
        in_degree = [0] * n
        g = [[] for j in range(n)]
        for r in richer:
            in_degree[r[1]] += 1
            g[r[0]].append(r[1])

        ans = [i for i in range(n)]

        q = queue.Queue()
        for i in range(n):
            if in_degree[i] == 0:
                q.put(i)

        while q.not_empty:
            pass
        print(ans)


if __name__ == '__main__':
    a = Solution()
    print(a.loudAndRich([[1, 0], [2, 1], [3, 1], [3, 7], [4, 3], [5, 3], [6, 3]], [3, 2, 5, 4, 6, 1, 7, 0]))
